package com.example.dmdomain.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Entity
@Getter
@Setter
@EntityListeners(AuditingEntityListener.class)
@Table(name = "user_log")
public class UseLog implements Serializable {
    @Id
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
    /**
     * 登录日志id
     */
    @Column(name = "use_log_id")
    private String useLogId;

    /**
     * 用户手机号
     */
    @Column(name = "user_phone")
    private String userPhone;

    /**
     * 用户手机号
     */
    @Column(name = "weixin_id")
    private String weixinId;

    /**
     * 登录方式
     */
    @Column(name = "login_type")
    private String loginType;

    /**
     * 登录IP地址
     */
    @Column(name = "login_ip")
    private String loginIp;

    /**
     * 登录时间
     */
    @CreatedDate
    @Column(name = "login_time")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date loginTime;

    /**
     * 登出时间
     */
    @LastModifiedDate
    @Column(name = "logout_time")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date logoutTime;

    public UseLog() {
    }
}
